package ifkm.kit.bremodroid;

import java.io.PrintStream;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;

public class ResultSectionFragment extends Fragment {

	
	public ResultSectionFragment() {
		
	}
	private EditText resultText;
	
	PrintStream outStream ;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		final View rootView = inflater.inflate(R.layout.fragment_main_result,
				container, false);
//		TextView dummyTextView = (TextView) rootView
//				.findViewById(R.id.section_label);
//		dummyTextView.setText(Integer.toString(getArguments().getInt(
//				ARG_SECTION_NUMBER)));
		outStream =  new PrintStream(System.out) {

			@Override
			public void println(final String s) {
				rootView.post(new Runnable() {

					@Override
					public void run() {
						// TODO Auto-generated method stub
						resultText.append(s + "\n");
					}
			    	
			    });
			}

			@Override
			public void print(final String s) {
				rootView.post(new Runnable() {

					@Override
					public void run() {
						// TODO Auto-generated method stub
						resultText.append(s + "\n");
					}
			    	
			    });
			}
		};
		
		resultText = (EditText) rootView.findViewById(R.id.editText1);
		return rootView;
	}
	
	public void setResultText() {
		System.setOut(outStream);
		
	}
}
